<!DOCTYPE html>
<html>
<body>
<h1>localStorage</h1>
<button onclick="saveData()">点我保存一个数据</button>
<button onclick="readData()">点我保存一个数据</button>
<button onclick="deleteData()">点我保存一个数据</button>
<button onclick="clearData()">点我保存一个数据</button>

<script>
  function saveData() {
    localStorage.setItem('name', '张三');
    localStorage.setItem('age', 18);
  }
  function readData() {
      console.log(localStorage.getItem('name'));
  }
  function deleteData() {
      localStorage.removeItem('name');
  }
  function clearData() {
      localStorage.clear();
  }
</script>

</body>
</html>